package io.vincentwinner.systeminfoapi.api;

import com.alibaba.fastjson.JSONObject;
import io.vincentwinner.systeminfoapi.dao.IOperatingSystemDao;
import io.vincentwinner.systeminfoapi.service.IDynamicInfoService;
import io.vincentwinner.systeminfoapi.service.IStaticInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/os")
public class OperatingSystemController {

    @Resource(name = "staticInfoService")
    private IStaticInfoService staticInfoService;

    @Resource(name = "dynamicInfoService")
    private IDynamicInfoService dynamicInfoService;

    @Resource(name = "osDao")
    private IOperatingSystemDao osDao;

    @RequestMapping
    public Object root(){
        JSONObject operatingSystemStaticInfo = staticInfoService.getOperatingSystemStaticInfo();
        operatingSystemStaticInfo.putAll(dynamicInfoService.getOperatingSystemDynamicInfo());
        return operatingSystemStaticInfo;
    }

    @RequestMapping("/static")
    public Object static$(){
        return staticInfoService.getOperatingSystemStaticInfo();
    }

    @RequestMapping("/dynamic")
    public Object dynamic(){
        return dynamicInfoService.getOperatingSystemDynamicInfo();
    }

    @RequestMapping("/name")
    public Object name(){
        return osDao.getOSName();
    }

    @RequestMapping("/arch")
    public Object arch(){
        return osDao.getArch();
    }

    @RequestMapping("/version")
    public Object version(){
        return osDao.getOSVersion();
    }

    @RequestMapping("/userName")
    public Object userName(){
        return osDao.getOSUserName();
    }

    @RequestMapping("/userHome")
    public Object userHome(){
        return osDao.getUserHome();
    }

    @RequestMapping("/lineSeparator")
    public Object lineSeparator(){
        return osDao.getLineSeparator();
    }

    @RequestMapping("/pathSeparator")
    public Object pathSeparator(){
        return osDao.getPathSeparator();
    }

    @RequestMapping("/fileSeparator")
    public Object fileSeparator(){
        return osDao.getFileSeparator();
    }

    @RequestMapping("/bit")
    public Object bit(){
        return osDao.getBit();
    }

    @RequestMapping("/sinceBootTime")
    public Object sinceBootTime(){
        return osDao.sinceBootTime();
    }

    @RequestMapping("/processCount")
    public Object processCount(){
        return osDao.getProcessesCount();
    }

    @RequestMapping("/threadCount")
    public Object threadCount(){
        return osDao.getThreadCount();
    }

}
